import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Observable, Subject } from 'rxjs';
import { catchError, map, tap } from 'rxjs/operators';
@Injectable({
  providedIn: 'root'
})
export class CusHttpServService {
  // private client: HttpClient;
  private baseUrl = '/lottery'; // 与proxy.config.json 中配置的语义一致，根目录就不需要加 /
  constructor(private client: HttpClient) {
  }
  public get<T> (url: string, header: object = null): Observable<T> {
    url = this.baseUrl + url;
    console.log('get url: ' + url);
    return this.client.get<T>(url, header);
  }
  public post<T> (url: string, data: object, header: object = null): Observable<T> {
    url = this.baseUrl + url;
    return this.client.post<T>(url, data, header);
  }
}
